<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *订单管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$return['status']=$this->team_status;
$return['noping']=$this->noping;
$tabs=array(
	array('op'=>'list','query'=>'status=100','title'=>'全部团'),
	array('op'=>'list','query'=>'status=0','title'=>'成团中'),
	array('op'=>'list','query'=>'status=1','title'=>'已成团'),
); 
if($_RQ['op']=='list'){
	$return['params']=array();
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(isset($_RQ['status']) && $_RQ['status']!=100){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=intval($_RQ['status']);
	}else{
		$return['params']['status']=100;
	}
	//我的团
	//先查询我的订单
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['psize']){
		$_SESSION['psize']=$_RQ['psize'];
	}
	$psize = $_SESSION['psize']?:10;
	$list=pdo_getslice('jy_paiweifee_team',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as $k=>&$item){
			$item['member']=cfc('core')->member_show($item['mid']);
			$item['isnum']=$this->model('team')->get_isnum($item['id']);
			$item['teamnum']=$this->model('team')->getteamnum($item);
			$item['bosslevel']++;
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','total'=>$total,'psize'=>$psize,'edit'=>false,'list'=>array(
			array('name'=>'member','title'=>'开团人','type'=>'member'),
			array('name'=>'id','title'=>'团ID','type'=>'string'),
			array('name'=>'p_teamid','title'=>'上级团ID','type'=>'string'),
			array('name'=>'bosslevel','title'=>'第几棵树','type'=>'string'),
			array('name'=>'level','title'=>'团层级','type'=>'string'),
			array('name'=>'num','title'=>'每层人数','type'=>'string'),
			array('name'=>'teamnum','title'=>'成团人数','type'=>'string'),
			array('name'=>'isnum','title'=>'已参与人数','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
		),'action'=>array(
			array('type'=>'href','action'=>'jy_paiweifee/log/','title'=>'参与人'),
		)),
		'search'=>array(
			array('name'=>'id','title'=>'团ID','type'=>'string','width'=>15),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_paiweifee_team',array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_paiweifee_team',array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
}
